#include <bits/stdc++.h>
using namespace std;
#define int long long
void solve()
{
    int a,b,c;
    cin>>a>>b>>c;
    int x=abs(a-b),y=abs(b-c);
    int ans=max(x,y);
    cout<<ans-1<<endl;
}
signed main()
{
    //ios::sync_with_stdio(false);
    //cin.tie(nullptr);
    int T=1;
    cin>>T;
    while(T--)
    {
       solve();
    }
    return 0;
}